Repository navigation
Conversation
| if (unlikely(ret)) | ||
| goto release; | ||
|
|
||
| if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) { |
There was a problem hiding this comment.
if the DSP is not booted at this point then we would not be able to load the library to fw in the first place, this check is redundant.
If the loading crashes the fw, then this would be skipped anyways.
| } | ||
| ret = sof_ipc4_compr_refresh_codec_info(sdev); | ||
| if (ret) | ||
| return ret; |
There was a problem hiding this comment.
Booting up the DSP and re-reading the info will not change anything, the info refresh after a library loading is the only place where it can change.
There was a problem hiding this comment.
So we need an API call here that can do 2 things:
-
Check the kernel info (refreshed after library loads) of what modules are in FW and return with a match/context in order to proceed here.
-
If no info match found, then we look at the FS for a match.
Now for 2) need a way for 3) kernel to know where to look on the FS for modules.
Re 3) I'm thinking our feature/function topology would be like NXP ipc3 decoder where we can have a container module and we could list UUIDs supported for this configuration. This list would allow the kernel to know which UUIDs would support 44.1k S16le MP3 or whicg UUIDs support 48k 24bit AAC etc.
i.e. kernel would know where to find UUID and hence llext module that would align with request.
| for (i = 0; i < codec_info->count; i++) { | ||
| int _dir = SOF_IPC4_CODEC_INFO_GET_DIR(codec_info->items[i]); | ||
| { | ||
| guard(mutex)(&ipc4_data->codec_info_mutex); |
There was a problem hiding this comment.
Use scoped_guard() instead if must
|
|
||
| ret = sof_ipc4_compr_refresh_codec_info(sdev); | ||
| if (ret) | ||
| return ret; |
There was a problem hiding this comment.
this is not needed, just booting up will not change anything in configuration, keep the existing flow.
| if (count) { | ||
| kfree(new_codec_info); | ||
| new_codec_info = kmemdup(tuple->value, tuple->size, GFP_KERNEL); | ||
| if (!new_codec_info) { |
There was a problem hiding this comment.
you expect multiple CODEC_INFO in the sof_info block and ignore all, but the last one?
When a module is loaded to the firmware, they cannot be unloaded, so the last codec_info should contain the cumulative list of all codecs, including if there are cadence codecs in basefw, ffmpeg codecs or any other codecs loaded as library via UUID.
Loading new codecs will not remove the existing ones.
There was a problem hiding this comment.
actually we do need to be able to purge modules. - we need to consider that non core modules can come and go (and this will also include models too).
| } | ||
|
|
||
| if (ipc4_data->sof_info_runtime_supported) { | ||
| ret = sof_ipc4_query_sof_info(sdev); |
There was a problem hiding this comment.
we just parsed the sof_info from fw_config, the separate sof_info_get will query different sof_info than the sof_info we just parsed?
| } | ||
| } | ||
|
|
||
| if (!ret && ipc4_data->sof_info_runtime_supported) |
There was a problem hiding this comment.
right, this code does not know if the libraries are indeed reloaded or it was a NOP due to the fact that on Intel hardware IMR stored the libraries.
There was a problem hiding this comment.
🟡 Changes recommended
The GET_CAPS refresh lacks a runtime-PM reference across firmware boot and capability querying, so it can access powered-down hardware and fail when SOF is suspended.
1 open issue
What changed in this PR
Adds runtime codec capability discovery to the SOF IPC4 driver, complementing the firmware changes in thesofproject/sof#11472 while preserving boot-time discovery for older firmware.
Changes:
- Defines the runtime SOF-info query and capability flag.
- Refreshes codec information after library loads and reloads, with tuple validation and mutex-protected cache replacement.
- Refreshes capabilities before compressed-stream queries and codec selection, and frees cached information at exit.
| File | Description |
|---|---|
sound/soc/sof/ipc4.c |
Initializes the codec-info mutex and frees cached data at exit. |
sound/soc/sof/ipc4-priv.h |
Declares runtime capability state, locking, and the query helper. |
sound/soc/sof/ipc4-loader.c |
Validates SOF-info tuples and refreshes capabilities during firmware and library setup. |
sound/soc/sof/ipc4-compress.c |
Refreshes and locks codec information used by compressed streams. |
include/sound/sof/ipc4/header.h |
Adds runtime SOF-info query and capability constants. |
Review effort: Balanced
| * Ensure the DSP is booted (on-demand boot) and runtime codec | ||
| * capabilities are synchronized before consulting codec_info. | ||
| */ | ||
| ret = snd_sof_boot_dsp_firmware(sdev); |
|
@ujfalusi I'm going to work on 3) below, so we have something similar to NXP in IPC4 - lets see if we can get a simple method for kernel to get UUIDs for needed modules |
cd8df21 to
42d44e9
Compare
|
Addressed review feedback and added module purge + topology format-to-UUID lookup:
|
Add IPC4 runtime SOF info discovery (SOF_IPC4_FW_PARAM_SOF_INFO_GET) and idle library unload (SOF_IPC4_FW_PARAM_SOF_LIBRARY_UNLOAD) gated by SOF_IPC4_SOF_CAPS capability flags, while keeping boot-time FW_CONFIG SOF_IPC4_SOF_CODEC_INFO parsing for backwards compatibility: - Protect cached codec_info with codec_info_mutex and reject duplicate SOF_IPC4_SOF_CODEC_INFO tuples in a single SOF_INFO payload. - Refresh SOF info on library load and non-IMR library reloads (avoiding redundant queries after FW_CONFIG or IMR restore). - Implement gap-safe library ID allocation, sof_ipc4_unload_library(), and automatic purging of idle unloadable UUID libraries when library slots or memory are exhausted. Signed-off-by: Liam Girdwood <[email protected]>
…d load Parse SOF_TKN_MEDIA_CODEC_* topology tokens on decoder widgets into swidget->media_formats[] mapping codec IDs and stream constraints to priority-ordered candidate module UUIDs: - Allow media_decoder widgets with media_formats[] to defer module binding at topology load time when their default UUID is not resident. - Report both cached firmware codec_info (under scoped_guard mutex) and topology media_formats[] in sof_ipc4_compr_get_caps() without waking or booting a suspended DSP. - In sof_ipc4_compr_set_params(), free any prior prepared stream first, then perform a two-tier lookup across matching media_formats[] (resident module first, else boot DSP and demand-load/purge UUID library) and bind the selected module before pipeline setup. Signed-off-by: Liam Girdwood <[email protected]>
42d44e9 to
c49efc5
Compare

Summary
Upgrade IPC4 codec discovery in the Linux SOF driver to support runtime codec queries (
SOF_IPC4_FW_PARAM_SOF_INFO_GET), idle dynamic library unloading/purging (SOF_IPC4_FW_PARAM_SOF_LIBRARY_UNLOAD), and topologymedia_decoderformat-to-UUID lookup with on-demand LLEXT loading — while preserving boot-timeFW_CONFIGfallback for older firmware.Companion SOF firmware PR: thesofproject/sof#11472
Changes
Runtime
SOF_INFOdiscovery & library unload (header.h,ipc4-priv.h,ipc4.c,ipc4-loader.c)SOF_IPC4_FW_PARAM_SOF_INFO_GET = 37,SOF_IPC4_FW_PARAM_SOF_LIBRARY_UNLOAD = 38,SOF_IPC4_SOF_CAP_RUNTIME_SOF_INFO, andSOF_IPC4_SOF_CAP_LIBRARY_UNLOAD.codec_infoupdates/reads withcodec_info_mutexand rejected duplicateSOF_IPC4_SOF_CODEC_INFOtuples in a single payload.SOF_INFOon library load and non-IMR library reloads (avoiding redundant queries afterFW_CONFIGor IMR restore).sof_ipc4_unload_library(), and automatic purging of idle unloadable UUID libraries when slots or memory are exhausted.media_decoderformat-to-UUID lookup & on-demand load (tokens.h,sof-audio.h,topology.c,ipc4-topology.h,ipc4-topology.c,ipc4-compress.c)SOF_TKN_MEDIA_CODEC_*(2200..2205) tokens intoswidget->media_formats[]and allowsmedia_decoderwidgets to defer module binding when their default UUID is not resident at topology load.codec_info(viascoped_guard(mutex, ...)) andmedia_formats[]insof_ipc4_compr_get_caps()without waking or booting a suspended DSP.sof_ipc4_compr_set_params(), tears down any previous prepared stream first (freeing prior LLEXT references for purge), then resolves the best matchingmedia_formats[]module UUID (resident module first, else boot DSP + demand-load/purge viasof_ipc4_find_module_by_uuid()) and binds it viasof_ipc4_process_bind_module().Verification
scripts/checkpatch.pl:0errors,0warnings on both commits.make M=sound/soc/sof: compiled and linked allsound/soc/sofmodules with0warnings and0errors.